<!DOCTYPE html>

<html lang = "en">
	<head>
		<meta charset = "UTF-8" />
		<meta name = "viewport" content = "width=device-width, initial-scale=1.0" />
		<meta name = "description" content = "Give safe and simple access to predefined shell commands from a web interface." />

		<title>OliveTin</title>

		<link rel = "stylesheet" type = "text/css" href = "/theme.css" />
		<link rel = "stylesheet" href = "node_modules/@xterm/xterm/css/xterm.css" />

		<link rel = "shortcut icon" type = "image/png" href = "OliveTinLogo.png" />

		<link rel = "apple-touch-icon" sizes="57x57" href="OliveTinLogo-57px.png" />
		<link rel = "apple-touch-icon" sizes="120x120" href="OliveTinLogo-120px.png" />
		<link rel = "apple-touch-icon" sizes="180x180" href="OliveTinLogo-180px.png" />

		<base href = "/" />
	</head>

	<body>
		<slot id = "app" />

		<noscript>
			<div class = "error">Sorry, JavaScript is required to use OliveTin.</div>
		</noscript>

		<dialog title = "Big Error Message" id = "big-error" class = "error padded-content">

		</dialog>

		<script type = "text/javascript">
			const bigErrorDialog = document.getElementById('big-error')

			/**
			This is the bootstrap code, which relies on very simple, old javascript
			to at least display a helpful error message if we can't use OliveTin.
			 */
			window.showBigError = function (type, friendlyType, message, isFatal) {
				console.error('Error ' + type + ': ', message)
				return;

				bigErrorDialog.innerHTML = '<h1>Error ' + friendlyType + '</h1><p>' + message + "</p><p><a href = 'http://docs.olivetin.app/troubleshooting/err-" + type + ".html' target = 'blank'/>" + type + " error in OliveTin Documentation</a></p>"

				if (isFatal) {
					bigErrorDialog.innerHTML += '<p>You will need to refresh your browser to clear this message.</p>'
				} else {
					bigErrorDialog.innerHTML += '<p>This error message will go away automatically if the problem is solved.</p>'
				}

				bigErrorDialog.showModal()

				console.error('Error ' + type + ': ', message)
			}

			window.clearBigErrors = function () {
				bigErrorDialog.close()
			}
		</script>

		<script type = "text/javascript" nomodule>
			showBigError("js-modules-not-supported", "Sorry, your browser does not support JavaScript modules.", null)
		</script>

		<script type = "module" src = "main.js"></script>
	</body>
</html>
